package com.chen.admin.service;


import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.chen.admin.common.Result;
import com.chen.admin.entity.HotelBooking;
import com.chen.admin.mapper.HotelBookingMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HotelBookingService {



    @Autowired
    private HotelBookingMapper hotelBookingMapper;

    public List<HotelBooking>getHotelBookings() {

        List<HotelBooking> hotelBookings = hotelBookingMapper.selectList(new LambdaQueryWrapper<>());
        if (ObjectUtil.isNull(hotelBookings))
        {
            return  null;
        }
        return hotelBookings;


    }

    public Result deleteHotelBookings(Integer id) {
       int count= hotelBookingMapper.deleteById(id);
       if(count==0){
           return Result.error("400","删除失败!");
       }
       return Result.success("删除成功！");
    }

    public Result deleteHotelBookingsByIds(List ids) {
        int count= hotelBookingMapper.deleteBatchIds(ids);
        if(count==0)
        {
            return  Result.error("400","删除失败");
        }
        return Result.success("删除成功");

    }

    public Result updateHotelBookings(HotelBooking hotelBooking) {

        int count = hotelBookingMapper.updateById(hotelBooking);
        if(count==0)
        {
            return Result.error("400","修改失败");
        }
        return Result.success("修改成功");
    }
}
